import request from '@/utils/request'

/* 
查看某个角色的权限列表
*/
export function getRoleById(id) {
    return request({ url: `/acl/permission/toAssign/${id}`, method: 'get' })
}

//获取菜单
export function getPermissions() {
    return request({ url: `/acl/permission`, method: 'get' })
}

//删除权限
export function delPermission(id) {
    return request({ url: `/acl/permission/remove/${id}`, method: 'delete' })
}


/* 
  获取权限(菜单/功能)列表
  */
export function getPermissionList() {
    return request({
        url: `/acl/permission`,
        method: 'get'
    })
}

/* 
删除一个权限项
*/
export function removePermission(id) {
    return request({
        url: `/acl/permission/remove/${id}`,
        method: "delete"
    })
}

/* 
保存一个权限项
*/
export function addPermission(permission) {
    return request({
        url: `/acl/permission/save`,
        method: "post",
        data: permission
    })
}

/* 
更新一个权限项
*/
export function updatePermission(permission) {
    return request({
        url: `/acl/permission/update`,
        method: "put",
        data: permission
    })
}

/* 
查看某个角色的权限列表
*/
export function toAssign(roleId) {
    return request({
        url: `/acl/permission/toAssign/${roleId}`,
        method: 'get'
    })
}

/* 
给某个角色授权
*/
export function doAssign(roleId, permissionId) {
    return request({
        url: `/acl/permission/doAssign`,
        method: "post",
        params: { roleId, permissionId }
    })
}
